/**
 * 
 */
package com.neal.web.controller.message;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import com.neal.domain.Message;
import com.neal.service.IMessageBoardService;


/**
 * @author Neal
 * @version 1.0
 * @description 
 */
@Controller
@RequestMapping("/messageDelete")
public class MessageDeleteController {
	private IMessageBoardService messageBoardService;

	@Autowired
	public MessageDeleteController(IMessageBoardService messageBoardService) {
		this.messageBoardService = messageBoardService;
	}
	
	@RequestMapping(method=RequestMethod.GET)
	public String messageDelete(@RequestParam Long messageId,Model model) {
		Message message = messageBoardService.findMessageById(messageId);
		messageBoardService.deleteMessage(message);
		model.addAttribute("messages", messageBoardService.listMessages());
		return "redirect:messageList";
	}
}
